package com.ruoyi.trainingManagement.controller;

import java.util.List;

import com.ruoyi.trainingManagement.domain.CourseScheduleDetails;
import com.ruoyi.trainingManagement.domain.Vo.ClassScheduleVo;
import com.ruoyi.trainingManagement.service.ICourseScheduleDetailsService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.trainingManagement.domain.ClassScheduleDetailed;
import com.ruoyi.trainingManagement.service.IClassScheduleDetailedService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课程完整上课时间Controller
 *
 * @author chenxl
 * @date 2025-07-07
 */
@RestController
@RequestMapping("/trainingManagement/classScheduleDetailed")
public class ClassScheduleDetailedController extends BaseController
{
    @Autowired
    private IClassScheduleDetailedService classScheduleDetailedService;
    @Autowired
    private ICourseScheduleDetailsService courseScheduleDetailsService;


    /**
     * 查询课程完整上课时间列表
     */
    //@PreAuthorize("@ss.hasPermi('trainingManagement:classScheduleDetailed:list')")
    @GetMapping("/list")
    public TableDataInfo list(ClassScheduleDetailed classScheduleDetailed)
    {
        startPage();
        List<ClassScheduleDetailed> list = classScheduleDetailedService.selectClassScheduleDetailedList(classScheduleDetailed);
        return getDataTable(list);
    }

    /**
     * 导出课程完整上课时间列表
     */
    @PreAuthorize("@ss.hasPermi('trainingManagement:classScheduleDetailed:export')")
    @Log(title = "课程完整上课时间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ClassScheduleDetailed classScheduleDetailed)
    {
        List<ClassScheduleDetailed> list = classScheduleDetailedService.selectClassScheduleDetailedList(classScheduleDetailed);
        ExcelUtil<ClassScheduleDetailed> util = new ExcelUtil<ClassScheduleDetailed>(ClassScheduleDetailed.class);
        util.exportExcel(response, list, "课程完整上课时间数据");
    }

    /**
     * 获取课程完整上课时间详细信息
     */
    @PreAuthorize("@ss.hasPermi('trainingManagement:classScheduleDetailed:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(classScheduleDetailedService.selectClassScheduleDetailedById(id));
    }

    /**
     * 新增课程完整上课时间
     */
    @PreAuthorize("@ss.hasPermi('trainingManagement:classScheduleDetailed:add')")
    @Log(title = "课程完整上课时间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ClassScheduleDetailed classScheduleDetailed)
    {
        return toAjax(classScheduleDetailedService.insertClassScheduleDetailed(classScheduleDetailed));
    }

    /**
     * 修改课程完整上课时间
     */
    @PreAuthorize("@ss.hasPermi('trainingManagement:classScheduleDetailed:edit')")
    @Log(title = "课程完整上课时间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ClassScheduleDetailed classScheduleDetailed)
    {
        return toAjax(classScheduleDetailedService.updateClassScheduleDetailed(classScheduleDetailed));
    }

    /**
     * 删除课程完整上课时间
     */
    @PreAuthorize("@ss.hasPermi('trainingManagement:classScheduleDetailed:remove')")
    @Log(title = "课程完整上课时间", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(classScheduleDetailedService.deleteClassScheduleDetailedByIds(ids));
    }

//    /**
//     * 根据courseScheduleDetailsId获取所有排课详细信息
//     *
//     * @param courseScheduleDetailsId 课程安排详情ID
//     * @return 排课详细信息列表
//     */
//    @GetMapping("/getAllByCourseScheduleDetailsId/{courseScheduleDetailsId}")
//    public List<ClassScheduleDetailed> getAllByCourseScheduleDetailsId(@PathVariable String courseScheduleDetailsId) {
//        CourseScheduleDetails courseScheduleDetails =courseScheduleDetailsService.selectCourseScheduleDetailsById(courseScheduleDetailsId);
//        ClassScheduleVo classScheduleVo = new ClassScheduleVo();
//        classScheduleVo.setClassScheduleDetailedList(classScheduleDetailedService.selectAllByCourseScheduleDetailsId(courseScheduleDetailsId));
//        classScheduleVo.setClassroomId(courseScheduleDetails.getClassroom());
//        return classScheduleDetailedService.selectAllByCourseScheduleDetailsId(courseScheduleDetailsId);
//    }
}
